# 基础类
# 配置跨域

import tornado.web

# 声明基类
class BaseHandler(tornado.web.RequestHandler):
    # 重写父类方法
    def set_default_headers(self):
        # 设置请求头
        print("开始设置")
        # 域名信息
        self.set_header("Access-Control-Allow-Origin","*")
        # 请求信息
        self.set_header("Access-Control-Allow-Headers","x-requested-with")
        # 请求方式
        self.set_header("Access-Control-Allow-Methods","POST,GET,PUT,DELETE")


    def post(self):
        self.write("这里是post请求")


    def get(self):
        self.write("这里是get请求")


    def put(self):
        self.write("这里是put请求")


    def delete(self):
        self.write("这里是delete请求")


    def options(self,*args):
        # 设置状态码
        self.set_status(204)
        self.finish()

